package net.tv90.bfmccore.listener;

import net.tv90.bfmccore.SlainListener;
import net.tv90.bfmccore.battlepass.Battlepass;
import net.tv90.bfmccore.constant.RewardConstant;
import net.tv90.bfmccore.util.Ribbon;
import org.bitterorange.flansmodslain.models.BukkitAmmoSupplyEvent;
import org.bitterorange.flansmodslain.models.BukkitHealSupplyEvent;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;

import java.util.Objects;

public class SupplyListener implements Listener {

    @EventHandler
    public void ammoSupplyEvent(BukkitAmmoSupplyEvent e) {
        Player supplier = e.getSupplier();
        Player supplied = e.getSupplied();
        if(!Objects.equals(supplier.getName(), supplied.getName())) {
            Battlepass.addBattlepassPoint(supplier, (int) (10 * RewardConstant.POINT_MAGNIFICATION));
            SlainListener.addLine(supplied, "补给者 " + supplier.getName(), 1);
            Ribbon.addNumberForRibbon(supplier,"Ammo","弹药补给",10);
        }
    }

    @EventHandler
    public void healSupplyEvent(BukkitHealSupplyEvent e) {
        Player supplier = e.getSupplier();
        Player supplied = e.getSupplied();
        if(!Objects.equals(supplier.getName(), supplied.getName())) {
            Battlepass.addBattlepassPoint(supplier, (int) (e.getHealAmount() * 2 * RewardConstant.POINT_MAGNIFICATION));
            SlainListener.addLine(supplied, "治疗者 " + supplier.getName(), 1);
            Ribbon.addNumberForRibbon(supplier,"Heal","医疗",20);
        }
    }
}
